#include "shm.hpp"
#include "fifo.hpp"


int main()
{
    //获取共享内存
    Shm shm(PATH,PROJID,USER);
    shm.CreateOrGet();
    //绑定共享内存
    char* ptr  = (char*)shm.Attach();
    int index = 0;
    //使用管道文件模拟同步
    PipeOper oper(PATH,FILE_NAME);
    oper.OpenForWrite();
    //写入内容
    for(char ch = 'A';ch <= 'B';ch++)
    {
        //等待server进程读完
        sleep(2);
        ptr[index] = ch;
        sleep(1);
        ptr[index+1] = ch;
        ptr[index+2] = 0;
        sleep(1);
        index+=2;
        //唤醒server进程
        oper.WakeUp();
    }

    oper.Close();
    return 0;
}